from redis import Redis

r = Redis(host='192.168.94.129',port=6379,decode_responses=True)  # 默认连本地

if __name__ == "__main__":
    try:
        # host port db等参数是可选项
        redis_obj = Redis()
        # 添加数据
        # result = redis_obj.set('name', '安娜')

        # 获取数据
        # result = redis_obj.get('name')

        # 数据修改
        redis_obj.set('name', '双双')
        result = redis_obj.get('name')
        print(result)
    except Exception as e:
        print(e)